import { GetDeptTreeListRes, CreateDeptReq, UpdateDeptReq } from './model/deptModel';
import { defHttp } from '@/utils/http/axios';

enum Api {
  Dept = '/system/dept',
  DeptTreeList = '/system/dept/tree',
  DeptWithId = '/system/dept/{dept_id}',
}

//dept
export const apiGetDeptTreeList = () => defHttp.get<GetDeptTreeListRes>({ url: Api.DeptTreeList });

export const apiCreateDept = (params: CreateDeptReq) =>
  defHttp.post({ url: Api.Dept, params: params });

export const apiUpdateDept = (params: UpdateDeptReq) =>
  defHttp.put({ url: Api.Dept, params: params });

export const apiDeleteDept = (deptId: number) =>
  defHttp.delete({ url: Api.DeptWithId.replace('{dept_id}', deptId.toString()) });
